package cn.rick.service.impl;

import cn.rick.entity.SysDictData;
import cn.rick.mapper.SysDictDataMapper;
import cn.rick.service.ISysDictDataService;
import cn.rick.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 字典数据表 服务实现类
 * </p>
 *
 * @author house_store
 * @since 2022-10-19 14:39:46
 */
@Service
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService {

    @Override
    public List<SysDictData> getDataByParams(SysDictData param) {
        LambdaQueryWrapper<SysDictData> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByAsc(SysDictData::getDictSort);

        if (StringUtils.isNotEmpty(param.getDictType())) {
            queryWrapper.eq(SysDictData::getDictType, param.getDictType());
        }

        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<SysDictData> getDataByDictId(Long dictId, String dictLabel, String status) {
        return baseMapper.getDataByDictId(dictId, dictLabel, status);
    }
}
